<?php

use yii\db\Migration;
//权限表的结构
/**
 * CREATE TABLE `permission` (
`id` int(5) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(50) NOT NULL COMMENT '名称',
`path` varchar(50) NOT NULL COMMENT 'URL',
`parent_id` int(3) unsigned DEFAULT '0' COMMENT '父分类',
`lft` int(5) unsigned NOT NULL DEFAULT '0' COMMENT '左边界',
`rght` int(5) unsigned NOT NULL DEFAULT '0' COMMENT '右边界',
`level` int(3) unsigned NOT NULL DEFAULT '0' COMMENT '级别',
`intro` text COMMENT '简介',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

 */

/**
 * Class m170404_155647_create_insert
 */

class m170404_155647_create_insert extends Migration
{
    public function up()
    {
        //通过数据迁移添加权限添加多条数据
        /** 添加商品表的权限 */
        $this->batchInsert('permission',[
            'id','name','path','intro','level','lft','rght','parent_id'
        ],[
            //商品的列表展示
            ['1','viewList','goods/list','查看商品列表','1','1','6','0'],
            ['2','viewList','goods/list','商品的搜索','2','2','5','1'],
            ['3','searchTitle','goods/search-title','商品列表页面的ajax搜索','3','3','4','1'],
            //商品的添加 //商品的编辑
            ['4','goodsAdd','goods/add','商品添加','1','1','14','0'],
            ['11','goodsedit','goods/edit','商品编辑','2','2','13','4'],
            ['5','goodsAdd_s_upload','goods/s-upload','商品logo上传','3','3','12','4'],
            ['6','goodsAdd_upload','goods/upload','商品intro上传图片','4','4','11','4'],
            ['7','goodsAdd_addAGallery','goods/add-gallery','商品相册添加','5','5','10','4'],
            ['8','goodsAdd_async_banner','goods/async-banner','商品相册异步上传','6','9','8','4'],
            ['9','goodsAdd_del-album','goods/del-album','商品相册异步删除','7','7','8','4'],


            //商品的查看
            ['10','goodsshow','goods/show','商品查看','1','1','2','0'],
            //商品的删除
            ['12','goodsdel','goods/del','商品删除','1','1','2','0'],
            //商品的回收站的查看
            ['13','goodsrecycleBin','goods/recycye-bin','商品回收站','1','1','6','0'],
            ['14','goodsrecovery','goods/recovery','商品恢复','2','2','5','13'],
            ['15','goodsdelete','goods/delete','商品彻底删除','3','3','4','13'],


        ]);
    }

    public function down()
    {
        //echo "m170404_155647_create_insert cannot be reverted.\n";

        //return false;
        return $this->delete('permission');
    }

    /*
    // Use safeUp/safeDown to run migration code within a transaction
    public function safeUp()
    {
    }

    public function safeDown()
    {
    }
    */
}
